// 一般状态
.@{surely-checkbox-prefix-cls} {
  .reset-component();
  *,
  *:before,
  *:after {
    box-sizing: border-box;
  }
  position: relative;
  line-height: unset;
  white-space: nowrap;
  outline: none;
  cursor: pointer;
  display: inline-block;
  align-items: center;
  &:hover &-inner,
  &-input:focus + &-inner {
    border-color: @surely-checkbox-color;
  }

  &-checked::after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid @surely-checkbox-color;
    border-radius: @border-radius-base;
    visibility: hidden;
    animation: surelyCheckboxEffect 0.36s ease-in-out;
    animation-fill-mode: backwards;
    content: '';
    box-sizing: border-box;
  }

  &:hover::after {
    visibility: visible;
  }

  &-inner {
    position: relative;
    top: 0;
    left: 0;
    display: block;
    width: @surely-checkbox-size;
    height: @surely-checkbox-size;
    direction: ltr;
    background-color: @surely-checkbox-check-bg;
    border: @surely-checkbox-border-width @table-border-style-base @border-color-base;
    border-radius: @surely-checkbox-border-radius;
    border-collapse: separate;
    transition: all 0.3s;
    box-sizing: border-box;
    &::after {
      @check-width: (@surely-checkbox-size / 14) * 5px;
      @check-height: (@surely-checkbox-size / 14) * 8px;

      position: absolute;
      top: 50%;
      left: 21.5%;
      display: table;
      width: @check-width;
      height: @check-height;
      border: 2px solid @surely-checkbox-color;
      border-top: 0;
      border-left: 0;
      transform: rotate(45deg) scale(0) translate(-50%, -50%);
      opacity: 0;
      transition: all 0.1s @ease-in-back, opacity 0.1s;
      content: ' ';
      box-sizing: border-box;
    }
  }

  &-input {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
  }
}

// 选中状态
.@{surely-checkbox-prefix-cls}-checked .@{surely-checkbox-inner-prefix-cls}::after {
  position: absolute;
  display: table;
  border: 2px solid @white;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg) scale(1) translate(-50%, -50%);
  opacity: 1;
  transition: all 0.2s @ease-out-back 0.1s;
  content: ' ';
}

.@{surely-checkbox-prefix-cls}-checked {
  .@{surely-checkbox-inner-prefix-cls} {
    background-color: @surely-checkbox-color;
    border-color: @surely-checkbox-color;
  }
}

.@{surely-checkbox-prefix-cls}-disabled {
  cursor: not-allowed;

  &.@{surely-checkbox-prefix-cls}-checked {
    .@{surely-checkbox-inner-prefix-cls}::after {
      border-color: ~'var(--@{surely-table-prefix-cls}-disabled-color)';
      animation-name: none;
    }
  }

  .@{surely-checkbox-prefix-cls}-input {
    cursor: not-allowed;
  }

  .@{surely-checkbox-inner-prefix-cls} {
    background-color: ~'var(--@{surely-table-prefix-cls}-disabled-bg)';
    border-color: @border-color-base !important;

    &::after {
      border-color: ~'var(--@{surely-table-prefix-cls}-disabled-bg)';
      border-collapse: separate;
      animation-name: none;
    }
  }

  & + span {
    color: ~'var(--@{surely-table-prefix-cls}-disabled-color)';
    cursor: not-allowed;
  }

  // Not show highlight border of checkbox when disabled
  &:hover::after {
    visibility: hidden;
  }
}

.@{surely-checkbox-prefix-cls} + span {
  padding-right: 8px;
  padding-left: 8px;
}

// 半选状态
.@{surely-checkbox-prefix-cls}-indeterminate {
  .@{surely-checkbox-inner-prefix-cls} {
    background-color: @surely-checkbox-check-bg;
    border-color: @border-color-base;
  }
  .@{surely-checkbox-inner-prefix-cls}::after {
    @indeterminate-width: @surely-checkbox-size - 8px;
    @indeterminate-height: @surely-checkbox-size - 8px;

    top: 50%;
    left: 50%;
    width: @indeterminate-width;
    height: @indeterminate-height;
    background-color: @surely-checkbox-color;
    border: 0;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    content: ' ';
  }

  &.@{surely-checkbox-prefix-cls}-disabled .@{surely-checkbox-inner-prefix-cls}::after {
    background-color: ~'var(--@{surely-table-prefix-cls}-disabled-color)';
    border-color: ~'var(--@{surely-table-prefix-cls}-disabled-color)';
  }
}

@keyframes surelyCheckboxEffect {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }

  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
